package com.drg.center.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.drg.center.entity.SysDoctorGroupPO;
import com.drg.center.mapper.SysDoctorGroupMapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SysDoctorGroupDAO extends BaseDAO<SysDoctorGroupMapper, SysDoctorGroupPO> {


    public List<SysDoctorGroupPO> findList(String keyword) {
        LambdaQueryWrapper<SysDoctorGroupPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(keyword)) {
            lambdaQueryWrapper.eq(SysDoctorGroupPO::getDoctorGroupCode, keyword).or(qw -> qw.like(SysDoctorGroupPO::getDoctorGroupName, keyword));
        }
        lambdaQueryWrapper.last("limit 0,20");
        lambdaQueryWrapper.orderByAsc(SysDoctorGroupPO::getDoctorGroupCode);
        return getBaseMapper().selectList(lambdaQueryWrapper);
    }
}
